﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace com.instalinks.android.web.web2sms
{
    public partial class Notify : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack && Request.HttpMethod == "POST")
            {
                DoNotify();
            }
        }

        private void DoNotify()
        {
            String authToken = Request["authtoken"];
            String registrationId = Request["registrationid"];
            String mode = HttpUtility.HtmlDecode(Request["mode"]);
            String appId = HttpUtility.HtmlDecode(Request["appid"]);
            String field1 = HttpUtility.HtmlDecode(Request["field1"]);
            String field2 = HttpUtility.HtmlDecode(Request["field2"]);
            String field3 = HttpUtility.HtmlDecode(Request["field3"]);
            String field4 = HttpUtility.HtmlDecode(Request["field4"]);

            String response = "";
            try
            {
                C2DMService srv = new C2DMService();
                response = srv.Notify(authToken, registrationId, mode, appId, field1, field2, field3, field4);
            }
            catch (Exception ex)
            {
                response = "error : " + ex.Message;
            }

            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();

            Response.ContentType = "text/plain";
            Response.Write(response);
            Response.End();
        }
    }
}